package com.uchiha.nova.mainService.wrapper;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.uchiha.nova.core.model.entity.VisitorPassRecordEntity;
import com.uchiha.nova.core.model.vo.VisitorPassRecordVO;
import com.uchiha.nova.core.tool.support.BaseEntityWrapper;
import com.uchiha.nova.core.tool.util.SpringUtil;
import com.uchiha.nova.mainService.service.IVisitorPassRecordService;

import java.util.List;
import java.util.stream.Collectors;
/**
 * 通行记录 包装类,返回视图层所需的字段
 *
 * @author Uchihashiamu
 */
public class VisitorPassRecordWrapper extends BaseEntityWrapper<VisitorPassRecordEntity, VisitorPassRecordVO>  {
  
  IVisitorPassRecordService visitorPassRecordService = SpringUtil.getBean(IVisitorPassRecordService.class);
  
	public static VisitorPassRecordWrapper build() {
		return new VisitorPassRecordWrapper();
 	}

	@Override
	public VisitorPassRecordVO entityVO(VisitorPassRecordEntity visitorPassRecordEntity) {
		VisitorPassRecordVO visitorPassRecordVO = new VisitorPassRecordVO();
		BeanUtil.copyProperties(visitorPassRecordEntity, visitorPassRecordVO);

		return visitorPassRecordVO;
	}
	public List<VisitorPassRecordVO> listVO(List<VisitorPassRecordEntity> list) {
		List<VisitorPassRecordVO> collect = list.stream().map(item -> {
            VisitorPassRecordVO visitorPassRecordVO = new VisitorPassRecordVO();
		    BeanUtil.copyProperties(item, visitorPassRecordVO);			
			return visitorPassRecordVO;
		}).collect(Collectors.toList());
		return collect;
    // return ForestNodeMerger.merge(collect);
	}
  
  	@Override
	public IPage<VisitorPassRecordVO> pageVO(IPage<VisitorPassRecordEntity> pages) {
		IPage<VisitorPassRecordVO> page = pages.convert(item->{
            VisitorPassRecordVO visitorPassRecordVO = new VisitorPassRecordVO();
		    BeanUtil.copyProperties(item, visitorPassRecordVO);			
			return visitorPassRecordVO;
		});
		return page;
	}
}
